// 文件名: TestSystem.java
// 包名（可选，如果要用包，比如 test，需放在对应文件夹下，并使用 javac/test/TestSystem.java 编译运行）

// 可以加上包名，比如：package test; （如果用包，需要相应目录结构）
// 这里为了简单，不使用包，直接写类

// 导入语句（本例中不需要特殊导入，使用 Java SE 自带类即可）

// 定义课程类
class Course {
    private String courseId;
    private String courseName;
    private String location;
    private String schedule;
    private int credit;

    public Course(String courseId, String courseName, String location, String schedule, int credit) {
        this.courseId = courseId;
        this.courseName = courseName;
        this.location = location;
        this.schedule = schedule;
        this.credit = credit;
    }

    public String getCourseId() {
        return courseId;
    }

    public String getCourseName() {
        return courseName;
    }

    public String getLocation() {
        return location;
    }

    public String getSchedule() {
        return schedule;
    }

    public int getCredit() {
        return credit;
    }

    // 打印课程信息
    public void printInfo() {
        System.out.println("  课程ID: " + courseId);
        System.out.println("  课程名称: " + courseName);
        System.out.println("  上课地点: " + location);
        System.out.println("  上课时间: " + schedule);
        System.out.println("  学分: " + credit);
    }
}

// 定义教师类
class Teacher {
    private String teacherId;
    private String name;
    private String gender;
    private java.util.List<Course> coursesTaught;

    public Teacher(String teacherId, String name, String gender) {
        this.teacherId = teacherId;
        this.name = name;
        this.gender = gender;
        this.coursesTaught = new java.util.ArrayList<>();
    }

    // 教师开课
    public void openCourse(Course course) {
        coursesTaught.add(course);
    }

    // 打印教师信息及所授课程
    public void printInfo() {
        System.out.println("===== 教师信息 =====");
        System.out.println("教师ID: " + teacherId);
        System.out.println("姓名: " + name);
        System.out.println("性别: " + gender);
        System.out.println("所授课程：");
        if (coursesTaught.isEmpty()) {
            System.out.println("  暂无课程");
        } else {
            for (Course c : coursesTaught) {
                System.out.println("  - " + c.getCourseName() + " (ID: " + c.getCourseId() + ")");
                c.printInfo(); // 打印详细课程信息
                System.out.println(); // 空行分隔
            }
        }
    }
}

// 定义学生类
class Student {
    private String studentId;
    private String name;
    private String gender;
    private java.util.List<Course> selectedCourses;

    public Student(String studentId, String name, String gender) {
        this.studentId = studentId;
        this.name = name;
        this.gender = gender;
        this.selectedCourses = new java.util.ArrayList<>();
    }

    // 学生选课
    public void selectCourse(Course course) {
        selectedCourses.add(course);
    }

    // 打印学生信息及选课情况
    public void printInfo() {
        System.out.println("===== 学生信息 =====");
        System.out.println("学号: " + studentId);
        System.out.println("姓名: " + name);
        System.out.println("性别: " + gender);
        System.out.println("选课情况：");
        if (selectedCourses.isEmpty()) {
            System.out.println("  暂无选课");
        } else {
            for (Course c : selectedCourses) {
                System.out.println("  - " + c.getCourseName() + " (ID: " + c.getCourseId() + ")");
                c.printInfo(); // 打印详细课程信息
                System.out.println(); // 空行分隔
            }
        }
    }
}

// 主程序入口
public class TestSystem {
    public static void main(String[] args) {
        // 创建课程
        Course math = new Course("C001", "高等数学", "教学楼A101", "周一 8:00-10:00", 4);
        Course java = new Course("C002", "Java编程", "教学楼B205", "周二 10:00-12:00", 3);

        // 创建教师与学生
        Teacher t1 = new Teacher("T001", "李老师", "女");
        Teacher t2 = new Teacher("T002", "王老师", "男");
        Student s1 = new Student("S001", "张三", "男");
        Student s2 = new Student("S002", "李四", "女");

        // 教师开课
        t1.openCourse(math);
        t2.openCourse(java);

        // 学生选课
        s1.selectCourse(math);
        s2.selectCourse(java);

        // 打印信息
        s1.printInfo();
        s2.printInfo();
        t1.printInfo();
        t2.printInfo();
    }
}